/**
* Oxide
*
* Copyright (c) 2011 Dinosaur Kick Pty Ltd, All rights reserved.
*
* This source code is made available under the "Modified BSD" licensing arrangement.
* See license.txt for details.
*/
// ----------------------------------------------------------------------------
#include <string>
#include <iterator>
#include <istream>
#include "lex/lexer.hpp"
#include "parse/parser.hpp"
#include "parse/result.hpp"
// ----------------------------------------------------------------------------
#ifndef O2_PARSE_PROCESS_INC
#define O2_PARSE_PROCESS_INC
namespace o2 {
// ----------------------------------------------------------------------------

template <typename IteratorT>
parse::basic_result<std::basic_string<typename std::iterator_traits<IteratorT>::value_type> > process(const IteratorT& begin, const IteratorT& end)
{
	typedef lex::basic_lexer<IteratorT> lexer_type;
	lexer_type lexer(begin, end);
	parse::basic_parser<typename lexer_type::iterator> parser(lexer.begin(), lexer.end());
	return parser.parse();
}

template <typename CharT, typename TraitsT, typename AllocT>
parse::basic_result<std::basic_string<CharT, TraitsT, AllocT> > process(const std::basic_string<CharT, TraitsT, AllocT>& string)
{
	return process(string.begin(), string.end());
}

template <typename CharT, typename TraitsT>
parse::basic_result<std::basic_string<CharT> > process(std::basic_istream<CharT, TraitsT>& stream)
{
	typedef std::istream_iterator<CharT, CharT> iter_type;
	stream.unsetf(std::ios::skipws);
	return process(iter_type(stream), iter_type());
}

// ----------------------------------------------------------------------------
} // namespace o2
#endif // O2_PARSE_PROCESS_INC
// ----------------------------------------------------------------------------
